package cn.enilu.flash.warpper;

import cn.enilu.flash.bean.entity.park.ParkingQuote;
import cn.enilu.flash.enums.body.ParkOwnerFlag;
import cn.enilu.flash.enums.body.ParkType;
import cn.enilu.flash.enums.body.QuoteType;
import cn.enilu.flash.enums.body.QuoteUnit;
import cn.enilu.flash.service.system.impl.ConstantFactory;
import cn.enilu.flash.utils.DateUtil;
import cn.enilu.flash.utils.StringUtils;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Description
 * @Author Spark
 * @Date Created in (2019/11/05 9:40)
 * @Version v1.0
 * @Modify
 **/
public class ParkQuoteRefWarpper extends BaseControllerWarpper {
    public ParkQuoteRefWarpper(List<Map<String, Object>> list) {
        super(list);
    }

    @Override
    public void warpTheMap(Map<String, Object> map) {
        if(StringUtils.isNotNullOrEmpty(map.get("parkingId"))) {
            map.put("parkingCode", ConstantFactory.me().getParkingCodeById((Long) map.get("parkingId")));
        }
        if(StringUtils.isNotNullOrEmpty(map.get("checked1")) && StringUtils.isNotNullOrEmpty(map.get("checked2"))) {
            map.put("quoteTypeName", QuoteType.valueOfCode((Integer)map.get("quoteType")));
            map.put("quoteUnitName", QuoteUnit.valueOfCode((Integer)map.get("quoteUnit")));
            map.put("check01", ((Integer)map.get("checked1")) != 0);
            map.put("check02", ((Integer)map.get("checked2")) != 0);
            if(StringUtils.isNotNullOrEmpty(map.get("startDate"))){
                map.put("startDateStr", DateUtil.getDay((Date)map.get("startDate")));
            }
            if(StringUtils.isNotNullOrEmpty(map.get("endtDate"))){
                map.put("endDateStr", DateUtil.getDay((Date)map.get("endtDate")));
            }
        }
        if(StringUtils.isNotNullOrEmpty(map.get("quoteId"))) {
            ParkingQuote quote = ConstantFactory.me().getParkingQuoteById((Long) map.get("quoteId"));
            if(quote != null){
                map.put("quoteType", QuoteType.valueOfCode(quote.getQuoteType()));
                map.put("quoteRange", quote.getQuoteRange());
                map.put("quoteUnit", QuoteUnit.valueOfCode(quote.getQuoteUnit()));
                map.put("quotePrice", quote.getQuotePrice());
            }else{
                map.put("quoteType", "--");
                map.put("quoteRange", "-");
                map.put("quoteUnit", "-");
                map.put("quotePrice", "--");
            }
        }


    }
}
